package com.a3dweijing.wetouch2.Util;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.a3dweijing.wetouch2.Common.CallBack;
import com.a3dweijing.wetouch2.R;

/**
 * Created by Administrator on 2018/4/4.
 */

public class ShareDialogHelp
{
    public static Dialog create(Context context, final CallBack callBack)
    {
        final Dialog mShareDialog = new Dialog(context, R.style.dialog_bottom_full);
        mShareDialog.setCanceledOnTouchOutside(true);
        mShareDialog.setCancelable(true);
        Window window = mShareDialog.getWindow();
        window.setGravity(Gravity.BOTTOM);
        window.setWindowAnimations(R.style.share_animation);
        View view = View.inflate(context, R.layout.wx_share_selector, null);
        view.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                if (mShareDialog != null && mShareDialog.isShowing())
                {
                    mShareDialog.dismiss();
                }
            }
        });
        view.findViewById(R.id.haoyou).setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                if (mShareDialog != null && mShareDialog.isShowing())
                {
                    callBack.doNext(view.getId(),null);
                    mShareDialog.dismiss();
                }
            }
        });
        view.findViewById(R.id.pengyouquan).setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                if (mShareDialog != null && mShareDialog.isShowing())
                {   callBack.doNext(view.getId(),null);
                    mShareDialog.dismiss();
                }
            }
        });
        view.findViewById(R.id.shouchang).setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View view)
            {
                if (mShareDialog != null && mShareDialog.isShowing())
                {   callBack.doNext(view.getId(),null);
                    mShareDialog.dismiss();
                }
            }
        });
        window.setContentView(view);
        window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);// 设置横向全屏
        return mShareDialog;
    }
}
